package com.colorful.insuranceproject.adapter;

import android.content.Context;
import android.support.annotation.NonNull;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.colorful.insuranceproject.R;
import com.colorful.insuranceproject.bean.MicroDrugListBean;
import com.lovely3x.common.adapter.BaseViewHolder;
import com.lovely3x.common.adapter.ListAdapter;

import java.util.List;

import butterknife.Bind;

/**
 * Created by handsome-Bob on 2017/9/6.
 */

public class MicroDrugListAdapter extends ListAdapter<MicroDrugListBean>{

    public MicroDrugListAdapter(List<MicroDrugListBean> datas, Context context) {
        super(datas, context);
    }

    @NonNull
    @Override
    public BaseViewHolder createViewHolder(int position, ViewGroup parent) {
        return new ViewHolder(getLayoutInflater().inflate(R.layout.view_micro_drug_item, parent, false));
    }

    @Override
    public void handleData(int position, @NonNull BaseViewHolder holder) {
        ViewHolder viewHolder = (ViewHolder) holder;
        MicroDrugListBean bean = datas.get(position);
        viewHolder.imgPic.setImageResource(bean.getImg());
        viewHolder.tvId.setText(bean.getText());
    }

    class ViewHolder extends BaseViewHolder{

        @Bind(R.id.img_pic)
        ImageView imgPic;

        @Bind(R.id.tv_id)
        TextView tvId;

        public ViewHolder(View rootView) {
            super(rootView);
        }
    }
}
